﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WebCore.Tools
{
    public static class CommonExtend
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string ToJsonString(this object obj) {
            return Newtonsoft.Json.JsonConvert.SerializeObject(obj);
        }   
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="json"></param>
        /// <returns></returns>
        public static T ToJsonObject<T>(this string json) {
            return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json);
        }
    }
}
